#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m][n];
  for (auto& line : a) {
    for (auto& x : line) {
      cin >> x;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      b[j][i] = a[i][j];
    }
  }
  for (auto& line : b) {
    for (auto& x : line) {
      cout << x << ' ';
    }
    cout << endl;
  }
}